﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.ComponentModel;

namespace IKYSWeb.UserControls
{
    public partial class Ascx_Tarih : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public DateTime Tarih
        {
            get
            {
                if (txtTarih.Text != "")
                {
                    DateTime deger = DateTime.MinValue;
                    DateTime.TryParse(txtTarih.Text, out  deger);
                    return deger;  
                }
                else
                    return DateTime.MinValue;
            }
            set
            {
                txtTarih.Text = value.ToShortDateString();
            }
        }
        public void Clear()
        {
            txtTarih.Text = "";
        }

        public bool ReadOnly
        {
            set
            {
                txtTarih.ReadOnly = value;
                txtTarih.CssClass = (value ? "" : "tarih");
            }
        }

        public bool AllowEmpty
        {
            set { rfvTarih.Enabled = !value; }
        }

        public string ValidationGroup
        {
            set { 
                rfvTarih.ValidationGroup = value;
                cvTarih.ValidationGroup = value;
            }
        }

        public string HataMesaji
        {
            set { rfvTarih.ErrorMessage = value; }
        }

        public Unit Width
        {
            set { txtTarih.Width = value; }
        }
    }
}